/**
 *
 */
package com.wedroid.r2d2.support.response;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.wedroid.r2d2.contact.Contact;

/**
 * @author lute
 *
 */
public class ContactResponse extends AbstractBaseResponse {

    private List<Contact> contacts;

    /* (non-Javadoc)
     * @see com.wedroid.r2d2.support.response.AbstractBaseResponse#parseInternal(com.alibaba.fastjson.JSONObject)
     */
    @Override
    protected void parseInternal(JSONObject object) {
        JSONArray jsonArray = object.getJSONArray("MemberList");
        contacts = new ArrayList<Contact>();
        for (int i = 0; i < jsonArray.size(); i++) {
            contacts.add(jsonArray.getObject(i, Contact.class));
        }
    }

    /**
     * @return the contacts
     */
    public List<Contact> getContacts() {
        return Collections.unmodifiableList(contacts);
    }

}
